package AdapterPattern;

/**
 * @Author: zhaojie
 * @Date: Created in 16:18 2018/6/26
 * @Description: 创建实现了 MediaPlayer 接口的实体类。
 */
public class AudioPlayer implements MediaPlayer{
    MediaAdapter mediaAdapter;
    public void play(String audioType, String fileName) {
            //播放 MP3 音乐文件的内置支持
        if(audioType.equalsIgnoreCase("mp3")){
            System.out.println("play mp3"+fileName);
        }
        //mediaAdapter 提供了播放其他文件格式的支持
        else if(audioType.equalsIgnoreCase("vlc")
                || audioType.equalsIgnoreCase("mp4")){
            mediaAdapter=new MediaAdapter(audioType);
            mediaAdapter.play(audioType,fileName);
        }
        else{
            System.out.println("Invalid media. "+
                    audioType + " format not supported");
        }

    }
}
